<%@ page language="java" contentType="text/html;charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ page import="entity.*, java.util.*" %>
<!DOCTYPE html>
<html>

<head>
    <%
        User loginUser = (User) session.getAttribute("lu"); //与head.jsp重复定义
        Map<Product, Integer> shoppingcar = (Map<Product, Integer>) session.getAttribute("sc");
    %>
    <title><%=loginUser.getUsername()%>的购物车</title>
</head>
<body>
<table border="1">
    <%for (Product p : shoppingcar.keySet()) {%>
    <tr>
        <td><%=p.getName()%>
        </td>
        <td><%=p.getPrice()%>RMB</td>
        <td><img src="<%=p.getPicPath()%>"/> </td>
        <td>
            <form action="add_to_car" method="post">
                <input type="hidden" name="pid" value="<%=p.getId()%>">
                <input type="hidden" name="count" value="1">
                <input type="submit" value="+">
            </form>
        </td>
        <td><%=shoppingcar.get(p)%>件</td>
        <td>
            <form action="sub_to_car" method="post">
                <input type="hidden" name="pid" value="<%=p.getId()%>">
                <input type="hidden" name="count" value="1">
                <input type="submit" value="-">
            </form>
        </td>
        <td><%=p.getPrice() * shoppingcar.get(p)%>RMB</td>
    </tr>
    <%}%>
</table>

总价：<br>
<a href="create_order">下订单</a>
</body>
</html>